package com.jefe.hudson.service.model;

import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
import com.liferay.portal.kernel.util.HtmlUtil;
import com.liferay.portal.model.impl.BaseModelImpl;

import java.io.Serializable;

import java.lang.reflect.Proxy;


public class UserPrefsClp extends BaseModelImpl<UserPrefs> implements UserPrefs {
    private long _id;
    private String _hudHost;
    private int _hudPort;
    private String _hudUser;
    private String _hudPass;

    public UserPrefsClp() {
    }

    public long getPrimaryKey() {
        return _id;
    }

    public void setPrimaryKey(long pk) {
        setId(pk);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_id);
    }

    public long getId() {
        return _id;
    }

    public void setId(long id) {
        _id = id;
    }

    public String getHudHost() {
        return _hudHost;
    }

    public void setHudHost(String hudHost) {
        _hudHost = hudHost;
    }

    public int getHudPort() {
        return _hudPort;
    }

    public void setHudPort(int hudPort) {
        _hudPort = hudPort;
    }

    public String getHudUser() {
        return _hudUser;
    }

    public void setHudUser(String hudUser) {
        _hudUser = hudUser;
    }

    public String getHudPass() {
        return _hudPass;
    }

    public void setHudPass(String hudPass) {
        _hudPass = hudPass;
    }

    public UserPrefs toEscapedModel() {
        if (isEscapedModel()) {
            return this;
        } else {
            UserPrefs model = new UserPrefsClp();

            model.setEscapedModel(true);

            model.setId(getId());
            model.setHudHost(HtmlUtil.escape(getHudHost()));
            model.setHudPort(getHudPort());
            model.setHudUser(HtmlUtil.escape(getHudUser()));
            model.setHudPass(HtmlUtil.escape(getHudPass()));

            model = (UserPrefs) Proxy.newProxyInstance(UserPrefs.class.getClassLoader(),
                    new Class[] { UserPrefs.class },
                    new ReadOnlyBeanHandler(model));

            return model;
        }
    }

    public Object clone() {
        UserPrefsClp clone = new UserPrefsClp();

        clone.setId(getId());
        clone.setHudHost(getHudHost());
        clone.setHudPort(getHudPort());
        clone.setHudUser(getHudUser());
        clone.setHudPass(getHudPass());

        return clone;
    }

    public int compareTo(UserPrefs userPrefs) {
        long pk = userPrefs.getPrimaryKey();

        if (getPrimaryKey() < pk) {
            return -1;
        } else if (getPrimaryKey() > pk) {
            return 1;
        } else {
            return 0;
        }
    }

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        UserPrefsClp userPrefs = null;

        try {
            userPrefs = (UserPrefsClp) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long pk = userPrefs.getPrimaryKey();

        if (getPrimaryKey() == pk) {
            return true;
        } else {
            return false;
        }
    }

    public int hashCode() {
        return (int) getPrimaryKey();
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();

        sb.append("{id=");
        sb.append(getId());
        sb.append(", hudHost=");
        sb.append(getHudHost());
        sb.append(", hudPort=");
        sb.append(getHudPort());
        sb.append(", hudUser=");
        sb.append(getHudUser());
        sb.append(", hudPass=");
        sb.append(getHudPass());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBuilder sb = new StringBuilder();

        sb.append("<model><model-name>");
        sb.append("com.jefe.hudson.service.model.UserPrefs");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>id</column-name><column-value><![CDATA[");
        sb.append(getId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>hudHost</column-name><column-value><![CDATA[");
        sb.append(getHudHost());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>hudPort</column-name><column-value><![CDATA[");
        sb.append(getHudPort());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>hudUser</column-name><column-value><![CDATA[");
        sb.append(getHudUser());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>hudPass</column-name><column-value><![CDATA[");
        sb.append(getHudPass());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
